home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
Transport
/
src
/
InetStream.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
1KB
|
57 lines
#include <stdio.h>
#include <osfcn.h>
#include <libc.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <iostream.h>
#include "Transport.h"
#include <RJS/Util.h>
extern "C" int rresvport(int *aport);
int RJS_InetStream::reserved_socket(int starting_port)
{
td = ::rresvport(&starting_port);
return RJS_Socket::check_syscall(td,"rresvport");
}
int RJS_InetStream::active(const RJS_InetAddress &ia)
{
if (!ia.ss_ok()) {
ss_set(RJS_Status(errno));
if (return_on_error) return 0;
RJS_Util::crash_and_burn("RJS_InetStream","open",ss_message());
}
if (inuse()) close();
if (socket() && connect(ia)) {
ss_set(SS_success);
sex=Active;
return 1;
}
if (!return_on_error)
RJS_Util::crash_and_burn("RJS_InetStream","socket_client",ss_message());
return 0;
}
int RJS_InetStream::passive(const RJS_InetAddress &is)
{
if (inuse()) close();
if (socket() && bind(is) && listen(SOMAXCONN)) {
ss_set(SS_success);
sex=Passive;
return 1;
}
if (!return_on_error)
RJS_Util::crash_and_burn("RJS_InetStream","socket_server",ss_message());
return 0;
}